package com.zsc.wxapp.controller.admin;

import com.github.pagehelper.PageInfo;
import com.zsc.wxapp.entity.dto.PricePageDTO;
import com.zsc.wxapp.entity.vo.CigaretteVO;
import com.zsc.wxapp.result.PageResult;
import com.zsc.wxapp.result.Result;
import com.zsc.wxapp.services.CigaretteService;
import com.zsc.wxapp.services.PriceTimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("/api/wxapp/admin/priceTime")
@RestController("adminPriceTimeController")
//@Api(tags = "管理员端价格相关接口")
@Slf4j
public class PriceTimeController {

    @Resource
    private PriceTimeService priceTimeService;
    @Resource
    private CigaretteService cigaretteService;


    /**
     * 管理员端获取零售价格列表
     * @param pricePageDTO 条件
     * @return PageResult
     */
    @GetMapping("/getPricePage")
//    @ApiOperation("分页查询所有卷烟价格")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataTypeClass = Integer.class),
//    })
    public Result<PageInfo> getPriceTime(PricePageDTO pricePageDTO) {
        log.info("获取每日价格");
        // 分页查询, 每页数据写死15条
        pricePageDTO.setPageSize(15);
        PageInfo pageResult = priceTimeService.AdminPriceTimePage(pricePageDTO);
        return Result.success(pageResult);
    }

    /**
     * 根据卷烟代码获取卷烟信息
     * @param productCode 卷烟代码
     * @return Result
     */
    @GetMapping("/getCigaretteInfo")
//    @ApiOperation("获取卷烟信息")
//    @ApiImplicitParam(name = "productCode", value = "卷烟代码", required = true, dataTypeClass = String.class)
    public Result<CigaretteVO> getCigaretteInfo(String productCode) {
        log.info("获取卷烟信息，productCode:{}", productCode);
        return Result.success(cigaretteService.getCigaretteInfo(productCode));
    }
}
